package com.twohand.admin.Controller;

import com.github.binarywang.wxpay.exception.WxPayException;
import com.twohand.admin.Annotation.Permission;
import com.twohand.admin.Dto.WxOrderListQueryDto;
import com.twohand.admin.Dto.pay.RefundDto;
import com.twohand.admin.Service.WxOrderService;
import com.twohand.admin.Util.PageResponse;
import com.twohand.admin.Vo.pay.PayOrderListVo;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;

import java.math.BigDecimal;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ASDW
 * @since 2024-06-30
 */
@RestController
@RequestMapping("/pay/wxOrder")
public class WxOrderController {
    @Autowired
    WxOrderService iWxOrderService;
    @Permission(value = "pay::wxorder")
    @GetMapping
    PageResponse<PayOrderListVo> getWxOrderList(WxOrderListQueryDto wxOrderListQueryDto){
        return iWxOrderService.getAllWxOrderList(wxOrderListQueryDto);
    }

//    @GetMapping("/{id}")
//    WxOrder getWxOrderById(@PathVariable Integer id){
//        return iWxOrderService.getWxOrderById(id);
//    }
//
//
//    @PostMapping
//    Boolean insert(@RequestBody WxOrder wx_order){
//        return iWxOrderService.insertWxOrder(wx_order);
//    }
//
//    @PutMapping
//    Boolean update(@RequestBody WxOrder wx_order){
//        return iWxOrderService.updateWxOrder(wx_order);
//    }
//
//    @DeleteMapping("/{id}")
//    Boolean del(@PathVariable Integer id){
//        return iWxOrderService.deleteWxOrderById(id);
//    }
    @Permission(value = "pay:wxrefund")
    @PostMapping("/refund")
    Boolean refund(@RequestBody RefundDto refundDto) throws WxPayException {
        return iWxOrderService.refund(refundDto);
    }
    @Permission(value = "pay:wxrefund")
    @GetMapping("/getCanRefundCount")
    BigDecimal getCanRefundCount(String no){
        return iWxOrderService.getCanRefundCount(no);
    }
}
